/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2023-10-10 20:56:31
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2023-11-27 18:07:55
 * @FilePath: /logsystem/logs/test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "../logs/zbtlog.hpp"
#include <unistd.h>
    
void test_log(const std::string &name) {
    DEBUG("%s", "测试开始");
    zbtlog::Logger::ptr logger = zbtlog::LoggerMannger::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");
    size_t count = 0;
    while(count < 200000){
        logger->fatal("测试日志-%d", count++);
    }    
    INFO("%s", "测试完毕");
}

int main()
{
    std::unique_ptr<zbtlog::LoggerBuilder> builder(new zbtlog::GloballLoggerBuilder());
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(zbtlog::LogLevel::value::WARN);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(zbtlog::LoggerType::LOGGER_ASYNC);

    //极限性能测试时使用的
    builder->buildEnableUnSafeAsync();
    
    builder->buildSink<zbtlog::FileSink>("./logfile/async.log");
    builder->buildSink<zbtlog::StdoutSink>();
    builder->buildSink<zbtlog::RollSinkBySize>("./logfile/roll-async-by-size", 1024 * 1024);
    builder->build();
    test_log("async_logger");

    return 0;
}
